#include"name_pipe.hpp"

int main()
{
    //1.以写的方式打开命名管道
    int fd = open(Path, O_WRONLY);
    if(fd <= 0)
    {
        cout << "open failed! errno: " << errno << "errdesc: " << strerror(errno) << endl;
        return 1;
    }
    cout << "open success!" << endl;

    //2.向命名管道中写入数据
    string str;
    while(1)
    {
        getline(cin, str);
        if(str == "quit")
            break;
        int n = write(fd, str.c_str(), sizeof(str) - 1);
        if(n == -1)
        {
            cout << "write failed! errno: " << errno << "errdesc: " << strerror(errno) << endl;
            break;
        }
    }
}